package com.ray.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ray.service.AdvancePurchaseService;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;

/**
 * 关于预采购的控制层
* <p>Title: AdvancePurchaseController</p>  
* <p>Description: </p>  
* @author 李斌  
* @date 2018年8月23日
 */
@Controller
@RequestMapping("/advancePurchase")
public class AdvancePurchaseController {
	
	@Autowired
	AdvancePurchaseService advancePurchaseService;
	
	/**
	 * 保存预采购单
	* @date 2018年8月23日 下午3:08:23 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/addAdvancePurchase")
	@ResponseBody
	public Map<String,Object> addAdvancePurchase(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		advancePurchaseService.addAdvancePurchase(map); 
		return ResponseUtil.ResponseResult("新增成功");
	}
	
	/**
	 * 查询预采购单
	* @date 2018年8月24日 下午2:00:42 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/getAdvancePurchase")
	@ResponseBody
	public Map<String,Object> getAdvancePurchase(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(advancePurchaseService.getAdvancePurchase(map));
	} 
	
	/**
	 * 通过订单信息获取预采购单信息
	* @date 2018年8月25日 上午7:56:38 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/getAdvancePurchaseByDetail")
	@ResponseBody
	public Map<String,Object> getAdvancePurchaseByDetail(HttpServletRequest request){
		Map<String,String> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(advancePurchaseService.getAdvancePurchaseByDetail(map));
	}
	
	@RequestMapping("/setLaterPhaseData")
	@ResponseBody
	public Map<String, Object> setLaterPhaseData(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		advancePurchaseService.setLaterPhaseData(map);
		return ResponseUtil.ResponseResult("操作成功"); 
	}
	
	/**
	 * 用于打印的预采购单
	* @date 2018年8月24日 下午2:24:45 
	* @author 李斌
	* @return Map<String,Object> 
	* @throws
	 */
	@RequestMapping("/getAdvancePurchaseByPrint")
	@ResponseBody
	public Map<String,Object> getAdvancePurchaseByPrint(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(advancePurchaseService.getAdvancePurchaseByPrint(map));
	}
	
	@RequestMapping("/deleteAdvancePurchaseByMainId")
	@ResponseBody
	public Map<String,Object> deleteAdvancePurchaseByMainId(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		advancePurchaseService.deleteAdvancePurchaseByMainId(map);
		return ResponseUtil.ResponseResult("操作成功");  
	}
	
	@RequestMapping("/agreeAdvancePurchaseByMainId")
	@ResponseBody
	public Map<String,Object> agreeAdvancePurchaseByMainId(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		advancePurchaseService.agreeAdvancePurchaseByMainId(map);
		return ResponseUtil.ResponseResult("操作成功");  
	}
	 
	@RequestMapping("/updateAdvancePurchaseByMainId")
	@ResponseBody 
	public Map<String,Object> updateAdvancePurchaseByMainId(HttpServletRequest request){
		Map<String,Object> map = RequestUtil.getRequestAllParam(request);
		advancePurchaseService.updateAdvancePurchaseByMainId(map);
		return ResponseUtil.ResponseResult("操作成功"); 
	}
	 
	
}
